<template>
  <div class="bg">
    <div class="receiveCardD">
      <div class="receiveCard">
        <div class="circleTop"></div>
        <div class="circleBottom"></div>
        <!-- 无门栏现金券 -->

        <div class="moneydiv" v-if="couponInfo.type == 2">
          <div class="money">
            <span class="greenChar">￥</span>
            <span class="greenMoney">{{couponInfo.reduce}}</span>
          </div>
          <div class="Kinds">
            {{ couponInfo.activeDeploy }}
          </div>
        </div>

        <!--打折券  -->

        <div class="moneydiv" v-if="couponInfo.type == 3">
          <div class="money">
            <span class="blueMoney">{{ couponInfo.discount }}</span>
            <span class="blueChar">折</span>
          </div>
          <div class="useKinds">
            {{ couponInfo.activeDeploy | activeDeployFilter }}
          </div>
        </div>

        <!--满减券  -->

        <div class="moneydiv" v-if="couponInfo.type == 1">
          <div class="money">
            <span class="redChar">￥</span>
            <span class="redMoney">{{couponInfo.reduce}}</span>
          </div>
          <div class="useKinds">
            {{ couponInfo.activeDeploy | activeDeployFilter }}
          </div>
        </div>
        <div class="content">
          <div class="contentTitle">
            {{couponInfo.couponsName}}
          </div>
          <!-- <div class="remainTime">
            剩余使用时间：<span class="time">30天</span>
          </div> -->
          <div class="notes">
            <div class="rectBox" v-if="couponInfo.availableDeal.indexOf('service')!=-1">
              服
            </div>
            <div class="rectBox" v-if="couponInfo.availableDeal.indexOf('goods')!=-1">
              商
            </div>
            <div class="rectBox" v-if="couponInfo.availableDeal.indexOf('vipCard')!=-1">
              卡
            </div>
          </div>
        </div>
        <!-- <div class="receiveState">
					<img src="../../assets/已领取@3x.png" class="recivedImage">
					<button class="nowGet" @tap="nowGet">立即领取</button>
				</div> -->
      </div>
    </div>
    <div class="detailInfo">
      <!-- <div class="codeBox">
        <div class="codeBg">
          <img src="../../assets/images/二维码背景@2x.png" width="100%" />
        </div>
        <div class="codeImage">
          <img :src="codeImageData" width="100%"/>
        </div>
      </div> -->
      <div class="textInfo">
        <div>
          <div class="infoHead">
            适用范围
          </div>
          <div class="infoDetail">
            <div class="infoDetailHead">
              <div class="detailTitle">服务</div
              ><div class="detailDescribe break">{{couponInfo.isAllService==0? couponInfo.availableServiceNames:'适用于全部服务'}}</div>
            </div>
            <div class="infoDetailHead">
              <div class="detailTitle ">商品</div
              ><div class="detailDescribe break">{{couponInfo.isAllGoods==0?couponInfo.availablegGoodsNames:'适用于全部商品'}}</div>
            </div>
            <div class="infoDetailHead">
              <div class="detailTitle">会员卡</div
              ><div class="detailDescribe break">{{couponInfo.isAllVipCard==0?couponInfo.availableVipCardNames:'适用于全部会员卡'}}</div>
            </div>
          </div>
        </div>
        <div>
          <div class="infoHead">
            适用说明
          </div>
          <div class="infoDetail">
            <div class="infoDetailHead">{{couponInfo.description}}</div>
          </div>
        </div>
      </div>
    </div>
		<div class="foot">
			<div  class="storeHeadImage" >
			  <img src="../../assets/images/shopjie@2x.png" width="100%"/>
			</div>
			
			<!-- 这里有个门店的轮播图 -->
					<div class="bannar">
						<van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
							<block v-for='(item,index) in banner' :key='index'>
								<van-swipe-item><img :src="item" alt=""></van-swipe-item>
							</block>
						</van-swipe>
					</div>
		</div>
    <div class="storeIntroduce">
      

      <div class="storeInfo">
        <div class="storeInfoDetail">
          <div  class="storeInfoIcon" >
            <img src="../../assets/images/门店@2x.png" width="100%"/>
          </div>
          <span class="storeInfoIconTitle">门店</span>
          <span class="blackText">{{ couponInfo.name }}</span>
        </div>
        <div class="storeInfoDetail">
          <div  class="storeInfoIcon" >
             <img src="../../assets/images/电话@2x.png" width="100%"/>
          </div>
          <span class="storeInfoIconTitle">电话</span>
          <span class="blueText">{{ couponInfo.phone }}</span>
        </div>
        <div class="storeInfoDetail">
          <div  class="storeInfoIcon" >
            <img src="../../assets/images/地址@2x.png" width="100%"/>
          </div>
          <span class="storeInfoIconTitle">地址</span>
          <span class="blueText">{{ couponInfo.address }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      couponInfo: {     //优惠券详细信息
        type:3,
        discount:'',
        activeDeploy:'',
        description:''
      },
      codeImageData:''  ,//优惠券二维码流数据
			banner:[],
    };
  },
  filters: {
    //过滤优惠券描述
    activeDeployFilter: function(data) {
     if(data!=undefined){
       return data.split("-")[0] + "可用";
     }
    }
  },
  created() {
		let data = {
			merchantCode:localStorage.getItem('merchantCode')
		}
		this.$api.merchant(data).then(res => {
			this.banner = res.data.publicityImgList
		})
    //获得路由传参
    const { id } = this.$route.query;
		let params={
			merchantCode:localStorage.getItem('merchantCode'),
			couponId:id
		}
		this.$api.info(params).then(res=>{
			if(res.code=='10000'){
				if(!!res.data.availableDeal){
				  res.data.availableDeal=res.data.availableDeal.split(',')
				}
				this.couponInfo=res.data
				this.$nextTick()
			}
		})
    //获得优惠券详细信息
  }
};
</script>

<style scoped lang="scss">
.receiveCardD {
  background-color: #f1f1f1;
  padding: 20px;

  .receiveCard {
    border-radius: 20px;
    display: flex;
    position: relative;

    .circleTop,
    .circleBottom {
      position: absolute;
      left: 178px;
      background-color: #f0f0f0;
      height: 20px;
      width: 40px;
    }

    .circleTop {
      top: 0px;
      border-bottom-left-radius: 20px;
      border-bottom-right-radius: 20px;
    }

    .circleBottom {
      bottom: 0px;
      border-top-left-radius: 20px;
      border-top-right-radius: 20px;
    }

    .moneydiv {
      height: 240px;
      width: 190px;
      border-right: 16px dotted #e1e1e1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background-color: #ffffff;
      border-radius: 10px 0 0 10px;
      .money {
        .greenChar {
          color: #27b77c;
          font-weight: bold;
          font-size: 45px;
        }
        .greenMoney {
          color: #27b77c;
          font-weight: bold;
          font-size: 70px;
        }
        .blueMoney {
          color: blue;
          font-weight: bold;
          font-size: 70px;
        }
        .blueChar {
          color: blue;
          font-weight: bold;
          font-size: 45px;
          position: relative;
          bottom: 5px;
        }
        .redChar {
          color: red;
          font-weight: bold;
          font-size: 45px;
        }
        .redMoney {
          color: red;
          font-weight: bold;
          font-size: 70px;
        }
      }

      .useKinds {
        color: #7d7d7d;
        font-size: 26px;
      }
    }

    .content {
      flex: 1;
      padding-left: 30px;
      height: 240px;
      background: #ffffff;
      border-radius: 0 10px 10px 0;
      .contentTitle {
        margin-top: 40px;
        font-size: 32px;
        color: #272727;
      }

      .remainTime {
        margin: 30px 0;
        font-size: 24px;
        color: #737373;
      }

      .notes {
        display: flex;
        margin-top: 60px;
        .rectBox {
          width: 40px;
          height: 40px;
          color: #bc8038;
          background-color: #feeaa4;
          border-radius: 5px;
          text-align: center;
          line-height: 40px;
          font-size: 24px;
          margin-right: 24px;
        }
      }
    }

    .receiveState {
      height: 240px;
      background: #ffffff;
      display: flex;
      align-items: center;
      position: relative;

      .recivedImage {
        height: 96px;
        width: 96px;
        position: absolute;
        top: 0;
        right: 0;
      }

      .nowGet {
        padding: 0;
        line-height: 50px;
        text-align: center;
        height: 50px;
        width: 140px;
        border-radius: 50px;
        font-size: 25px;
        margin-right: 30px;
        color: #675400;
        background-color: yellow;
      }
    }
  }
}

.detailInfo {
  .codeBox {
    height: 386px;
    width: 386px;
    margin: 54px auto;
    position: relative;
    .codeBg {
      height: 100%;
      width: 100%;
    }
    .codeImage{
      width: 300px;
      height: 300px;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-left: -150px;
      margin-top: -150px;
    }
  }

  .textInfo {
    padding: 0 50px;
		padding-top: 50px;
    .infoHead {
      font-size: 32px;
      color: #272727;
      margin-bottom: 30px;
    }

    .infoDetail {
      .infoDetailHead {
				width: 100%;
        font-size: 26px;
        color: #7d7d7d;
        margin-bottom: 50px;
				display: flex;
        .detailTitle {
          display: inline-block;
          width: 20%;
        }
        .detailDescribe {
          color: #272525;
					width: 80%;
        }
      }
    }
  }
}

  .storeHeadImage {
    display: block;
    margin: 0px auto;
    padding: 30px 0;
    width: 144px;
    height: 42px;
  }
.storeIntroduce {
	// width: 100%;
	margin-top: 10px;
	padding-bottom: 100px;
  
	padding-left: 30px;
  background-color: #fff;
  .storeInfo {
    .storeInfoDetail {
      font-size: 32px;
      color: #7d7d7d;
      margin-top: 30px;
      .storeInfoIcon {
        // vertical-align: middle;
        width: 30px;
        height: 34px;
        display: inline-block;
      }
      .storeInfoIconTitle {
        display: inline-block;
        width: 140px;
        margin-left: 60px;
      }
      .blueText {
        color: #4883c0;
      }
      .blackText {
        color: #272525;
      }
    }
  }
}
 .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
		height: 600px;
		// width: 100%;
    text-align: center;
    background-color: #fff;
  }
	.my-swipe{
		height: 400px;
		width: 91%;
		// padding-right: 30px;
	}
	.bannar{
		width: 100%;
		display: flex;
		justify-content: center;
	}
	.bannar img{
		width: 100%;
		height: 100%;
	}
</style>
